package cn.com.infohold.smartcity.api;

import java.io.Serializable;

/**
 * Created by Mr.Fan on 2017/3/25.
 */

public class HttpEvent<T> implements Serializable {

    public static final int STATE_UNKNOWN = -1;
    public static final int STATE_SUCCESS = 1;
    public static final int STATE_FAILURE = 2;
    public static final int STATE_TIMEOUT = 3;
    public static final int STATE_CANCEL = 4;

    private int requestCode;

    private int state = STATE_UNKNOWN;

    private T data;

    private Throwable error;

    public HttpEvent(Integer requestCode, int state, T data) {
        this.requestCode = requestCode != null ? requestCode : 0;
        this.state = state;
        this.data = data;
    }

    protected void setError(Throwable e) {
        this.error = e;
    }

    public int getRequestCode() {
        return requestCode;
    }

    public T getData() {
        return data;
    }

    public int getState() {
        return state;
    }

    public Throwable getError() {
        return error;
    }
}
